<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>Return an explanation of the query, often useful for optimization and debugging</title>

 </head>
 <body><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="mongocursor.doquery.html">MongoCursor::doQuery</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="mongocursor.fields.html">MongoCursor::fields</a></div>
 <div class="up"><a href="class.mongocursor.html">MongoCursor</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div><hr /><div id="mongocursor.explain" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">MongoCursor::explain</h1>
  <p class="verinfo">(PECL mongo &gt;=0.9.2)</p><p class="refpurpose"><span class="refname">MongoCursor::explain</span> &mdash; <span class="dc-title">Return an explanation of the query, often useful for optimization and debugging</span></p>

 </div>

 <div class="refsect1 description" id="refsect1-mongocursor.explain-description">
  <h3 class="title">说明</h3>
  <div class="methodsynopsis dc-description">
   <span class="modifier">public</span> <span class="type">array</span> <span class="methodname"><strong>MongoCursor::explain</strong></span>
    ( <span class="methodparam">void</span>
   )</div>

 </div>


 <div class="refsect1 parameters" id="refsect1-mongocursor.explain-parameters">
  <h3 class="title">参数</h3>
  <p class="para">此函数没有参数。</p>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-mongocursor.explain-returnvalues">
  <h3 class="title">返回值</h3>  
  <p class="para">
   Returns an explanation of the query.
  </p>
 </div>

 <div class="refsect1 examples" id="refsect1-mongocursor.explain-examples">
  <h3 class="title">范例</h3>
  <div class="example" id="example-1450">
   <p><strong>Example #1 <span class="function"><strong>MongoCursor::explain()</strong></span> example</strong></p>
   <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br /><br />$cursor&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">$collection</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">find</span><span style="color: #007700">(array(</span><span style="color: #DD0000">"x"</span><span style="color: #007700">=&gt;</span><span style="color: #0000BB">1</span><span style="color: #007700">),&nbsp;array(</span><span style="color: #DD0000">"y"</span><span style="color: #007700">));<br /></span><span style="color: #0000BB">$cursor</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">sort</span><span style="color: #007700">(array(</span><span style="color: #DD0000">"z"&nbsp;</span><span style="color: #007700">=&gt;&nbsp;</span><span style="color: #0000BB">1</span><span style="color: #007700">))-&gt;</span><span style="color: #0000BB">limit</span><span style="color: #007700">(</span><span style="color: #0000BB">4</span><span style="color: #007700">)-&gt;</span><span style="color: #0000BB">skip</span><span style="color: #007700">(</span><span style="color: #0000BB">5</span><span style="color: #007700">);<br /><br /></span><span style="color: #0000BB">var_dump</span><span style="color: #007700">(</span><span style="color: #0000BB">$cursor</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">explain</span><span style="color: #007700">());<br /><br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</code></div>
   </div>

   <div class="example-contents"><p>以上例程的输出类似于：</p></div>
   <div class="example-contents screen">
<div class="cdata"><pre>
array(8) {
  [&quot;cursor&quot;]=&gt;
  string(15) &quot;BtreeCursor x_1&quot;
  [&quot;startKey&quot;]=&gt;
  array(1) {
    [&quot;x&quot;]=&gt;
    int(1)
  }
  [&quot;endKey&quot;]=&gt;
  array(1) {
    [&quot;x&quot;]=&gt;
    int(1)
  }
  [&quot;nscanned&quot;]=&gt;
  float(4)
  [&quot;n&quot;]=&gt;
  int(4)
  [&quot;scanAndOrder&quot;]=&gt;
  int(1)
  [&quot;millis&quot;]=&gt;
  int(3)
  [&quot;allPlans&quot;]=&gt;
  array(2) {
    [0]=&gt;
    array(3) {
      [&quot;cursor&quot;]=&gt;
      string(15) &quot;BtreeCursor x_1&quot;
      [&quot;startKey&quot;]=&gt;
      array(1) {
        [&quot;x&quot;]=&gt;
        int(1)
      }
      [&quot;endKey&quot;]=&gt;
      array(1) {
        [&quot;x&quot;]=&gt;
        int(1)
      }
    }
    [1]=&gt;
    array(3) {
      [&quot;cursor&quot;]=&gt;
      string(11) &quot;BasicCursor&quot;
      [&quot;startKey&quot;]=&gt;
      array(0) {
      }
      [&quot;endKey&quot;]=&gt;
      array(0) {
      }
    }
  }
}
</pre></div>
   </div>
  </div>
 </div>

 <div class="refsect1 errors" id="refsect1-mongocursor.explain-errors">
  <h3 class="title">错误／异常</h3>
  <p class="para">
   Throws <a href="class.mongoconnectionexception.html" class="classname">MongoConnectionException</a> if it cannot reach the 
   database.
  </p>
 </div>


 <div class="refsect1 seealso" id="refsect1-mongocursor.explain-seealso">
  <h3 class="title">参见</h3>
  <p class="para">
   MongoDB core docs on <a href="http://docs.mongodb.org/manual/reference/method/cursor.explain/" class="link external">&raquo;&nbsp;explain</a>.
  </p>
 </div>


</div><hr /><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="mongocursor.doquery.html">MongoCursor::doQuery</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="mongocursor.fields.html">MongoCursor::fields</a></div>
 <div class="up"><a href="class.mongocursor.html">MongoCursor</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div></body></html>
